<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        button{
            margin-left: 100px;
            margin-top: 20px;
            width: 50px;
        }
    </style>
</head>
<body>
    <form action="/logon" method="POST" id="form">
        账号：<input type="text" name="username"><br>

        密码：<input type="password" name="pwd"><br>
        密码：<input type="password" id="ewpwd"><br>
        <button>注册</button>

    </form>

    <script>

        let form = document.querySelector("#form")
        let pwd = document.getElementsByName("pwd")[0]
        let pwd1 = document.querySelector("#ewpwd")
        form.onsubmit = (e)=>{
            if(pwd.value != pwd1.value){
                alert("密码请输入一致")
                e.preventDefault()
            }else{
                alert("注册成功")
            }
        }

    </script>
</body>
</html>